<script>
/*
* operations after adding user
* print errors or add the new user to the displaying grid
*/
function afterAddUser(data)
{
	if(data=='adduser-success')
	{
		previousUserID=0;
		closeAddUsersInfoWindow();
		$.fn.yiiGridView.update("otherusersTable");//update grid view;
	}
	else
	{
		var errMessage='';
		for(var key in data)
		{
			errMessage+=data[key]+'<br>';
		}
		document.getElementById('adduser-error-area').innerHTML=errMessage;
	}
}
</script>

<?php $adduser_form = $this->beginWidget('CActiveForm', array(
		'id'=>'adduser-form',
		'enableClientValidation'=>true,
	//	'enableAjaxValidation'=>true,
		));
?>
<?php $prefix='adduser_'; ?>

<div id='adduser-error-area' align='left' style='color:#FF0000'>
</div>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th>FIRST NAME</th>
    <td>
    	<div class="rstep1-box5">
    		<?php echo CHtml::textField($prefix.'contact_first_name', ''); ?>
    	</div>
    </td>
  </tr>
    <tr>
    <th>LAST NAME</th>
    <td>
    	<div class="rstep1-box5">
    		<?php echo CHtml::textField($prefix.'contact_last_name', ''); ?>
    	</div>
    </td>
  </tr>
  <tr>
    <th>PHONE NUMBER</th>
    <td>
    	<div class="rstep1-box5">
    		<?php echo CHtml::textField($prefix.'phoneNumber', ''); ?>
    	</div>
    </td>
  </tr>
  <tr>
    <th>EMAIL ADDRESS</th>
    <td>
    	<div class="rstep1-box5">
			<?php echo CHtml::textField($prefix.'emailAddress', ''); ?>
    	</div>
    </td>
  </tr>
    <tr>
    <th>ROLE TYPE</th>
    <td><div class="rstep1-box5">
   		<?php echo CHtml::dropDownList($prefix.'user_role_type_ID', '',
							UserRoleType::model()->loadRoleTypes(),
							array('style'=>"width:282px;")
							); ?>
    </div></td>
  </tr>
    <tr>
    <th>USERNAME</th>
    <td>
    	<div class="rstep1-box5">
			 <?php echo CHtml::textField($prefix.'user_name', ''); ?>
    	</div>
    </td>
  </tr>
    <tr>
    <th>PASSWORD</th>
    <td>
    	<div class="rstep1-box5">
			<?php echo CHtml::passwordField($prefix.'password', ''); ?>
    	</div>
    </td>
  </tr>
    <tr>
    <th>RETYPE PASSWORD</th>
    <td>
    	<div class="rstep1-box5">
			<?php echo CHtml::passwordField($prefix.'password2', ''); ?>
    	</div>
    </td>
  </tr>
</table>
 <div align='center'>
 	<?php echo CHtml::imageButton(Yii::app()->request->baseUrl.'/images/submit.jpg', array(
										'ajax'=>array(				
											'type'=>'POST',
											'url'=>CController::createUrl('admin/addUser'),
											'success'=>'afterAddUser',
											'dataType'=>'json',
										),
									)
								); ?>
 </div>
 
 <?php $this->endWidget();?>